<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
    <a class="navbar-brand hidden-sm-down" href="{{ path('jury_index') }}">DOMjudge</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#menuDefault" aria-controls="menuDefault" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="menuDefault" data-update-url="{{ path('jury_ajax_updates') }}">
        <ul class="navbar-nav mr-auto">

            {% if is_granted('ROLE_BALLOON') %}
                <li class="nav-item">
                    <a class="nav-link" href="{{ path('jury_balloons') }}">
                        <i class="fas fa-map-marker-alt"></i> balloons
                        <span class="badge badge-info" id="num-alerts-balloons"></span>
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="{{ path('jury_prints') }}"><i class="fas fa-print"></i> printings</a>
                </li>
            {% endif %}

            {% if is_granted('ROLE_ADMIN') %}
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownJudgehosts" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        <i class="fas fa-gavel"></i> judgehosts
                        <span class="badge badge-warning" id="num-alerts-judgehosts"></span>
                        <span class="badge badge-danger" id="num-alerts-internalerrors"></span>
                    </a>
                    <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                        <a class="dropdown-item" href="{{ path('jury_judgehosts') }}" id="menu_judgehosts">
                            <i class="fas fa-server fa-fw"></i> judgehosts <span class="badge badge-warning" id="num-alerts-judgehosts-sub"></span>
                        </a>
                        <a class="dropdown-item dropdown-disabled" href="{{ path('jury_internal_errors') }}" id="menu_internal_error">
                            <i class="fas fa-bolt fa-fw"></i> internal error <span class="badge badge-danger" id="num-alerts-internalerrors-sub"></span>
                        </a>
                    </div>
                </li>
            {% endif %}

            {% if is_granted('ROLE_JURY') %}
                <li class="nav-item">
                    <a class="nav-link" href="{{ path('jury_clarifications') }}" id="menu_clarifications"><i class="fas fa-comments"></i> clarifications <span class="badge badge-info" id="num-alerts-clarifications"></span></a>
                </li>


                <li class="nav-item">
                    <a class="nav-link" href="{{ path('jury_submissions') }}"><i class="fas fa-file-code"></i> submissions</a>
                </li>

                {% if show_shadow_differences %}
                    <li class="nav-item">
                        <a class="nav-link" href="{{ path('jury_shadow_differences') }}"><i class="fas fa-not-equal"></i> shadow differences</a>
                    </li>
                {% endif %}

                <li class="nav-item">
                    <a class="nav-link" href="{{ path('jury_rejudgings') }}" id="menu_rejudgings"><i class="fas fa-sync"></i> rejudgings <span class="badge badge-info" id="num-alerts-rejudgings"></span></a>
                </li>
            {% endif %}

            {% if is_granted('ROLE_JURY') %}
                <li class="nav-item">
                    <a class="nav-link" href="{{ path('jury_scoreboard') }}"><i class="fas fa-list-ol"></i> scoreboard</a>
                </li>
            {% endif %}
            {% if is_granted('ROLE_TEAM') %}
                <li class="nav-item">
                    <a class="nav-link" target="_top" href="{{ path('team_index') }}"><i class="fas fa-arrow-right"></i> team</a>
                </li>
            {% endif %}
        </ul>

        <ul class="navbar-nav ml-auto">
            {# Render user information + logout button #}
            {% if is_granted('IS_AUTHENTICATED_FULLY') %}
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        <i class="fas fa-user"></i> {{ app.user.getUsername() }}
                    </a>
                    <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                        {% if app.user and app.user.getName() %}
                            <a class="dropdown-item disabled" href="#">{{ app.user.getName() }}</a>
                        {% endif %}

                        <a class="dropdown-item d-none" href="#" id="notify_disable">
                            <i class="fas fa-bell-slash fa-fw"></i> Disable Notifications
                        </a>
                        <a class="dropdown-item d-none" href="#" id="notify_enable">
                            <i class="fas fa-bell fa-fw"></i> Enable Notifications
                        </a>

                        {% if refresh is defined and refresh %}
                            <a class="dropdown-item" href="#" id="refresh-navitem">
                                <i class="fas fa-sync-alt fa-fw"></i> <span id="refresh-toggle">
                  {% if refresh_flag %}
                      Disable Refresh
                  {% else %}
                      Enable Refresh
                  {% endif %}
                </span>
                                {% if refresh %}
                                    <span class="small text-muted">({{ refresh.after }}s)</span>
                                {% endif %}
                            </a>
                        {% endif %}

                        <a class="dropdown-item" href="{{ path('logout') }}"><i class="fas fa-sign-out-alt fa-fw"></i>Logout </a>
                    </div>
                </li>
            {% else %}
                <li class="nav-item">
                    <a class="nav-link" target="_top" href="{{ path('login') }}"><i class="fas fa-sign-in-alt fa-fw"></i> log in</a>
                </li>
            {% endif %}

            {% include 'partials/menu_change_contest.html.twig' with {contest: current_contest, contests: current_contests, change_path: 'jury_change_contest', show_no_contest: true} %}
        </ul>
        {% include 'partials/menu_countdown.html.twig' with {contest: current_contest} %}
    </div>
</nav>
